package dao

import (
	"fmt"
)

type scenes struct {
	Name string `json:name gorm:"column:name"`
	UserName string `json:username gorm:"column:username"`
	PassWord string `json:password gorm:"column:password"`
	Ip string `json:ip gorm:"column:ip"`
	Subnet string `json:subnet gorm:"column:subnet"`
	GateWay string `json:gateway gorm:"column:gateway"`
	ImgUuid string `json:img_uuid gorm:"column:img_uuid"`
	IoUuid string `json:io_uuid gorm:"column:io_uuid"`
}

func (t *scenes)FirstById(bj_id float64) *scenes {

	err := db.Table("bc_bj").
		Select("bc_bj.name,bc_bj.username,bc_bj.password,bc_bj.ip,bc_bj.subnet,bc_bj.gateway," +
			"image.uuid as img_uuid," +
			"io.resource_uuid as io_uuid").
		Joins("left join bc_image as image on bc_bj.img_id=image.img_id").
		Joins("left join bc_instance_offering as io on io.io_id = bc_bj.ins_id").
		Where("bc_bj.bj_id=?",bj_id).
		First(&t).Error

	if err != nil {
		fmt.Println(err)
	}

	return t
}
var SenceDao = &scenes{}
